#ifndef TC_SECURITYADAPTOR_HPP
#define TC_SECURITYADAPTOR_HPP

/** \file SecurityAdaptor.hpp
 * Declarations for the templated class SecurityAdaptor.
 *
 * (C) Copyright by Semih Cemiloglu
 * All rights reserved, see COPYRIGHT file for details.
 *
 * $Id: SecurityAdaptor.hpp 110 2006-06-19 03:38:33Z semihc $
 *
 *
 */

#include "TA.hh"


namespace TC {


  /**
     Adaptor class which is used by TA algorithms to access
     price/volume tuple elements.
   */
  template <class S>
  class SecurityAdaptor
  {
  public:
    // TYPES
    typedef typename S::Price_t Price_t;
    typedef typename S::Volume_t Volume_t;

    // ACCESSORS
    Price_t opn(const S& sec) const 
    { return sec.getOpn(); }
    Price_t hi(const S& sec) const 
    { return sec.getHi();  }
    Price_t lo(const S& sec) const 
    { return sec.getLo();  }
    Price_t cls(const S& sec) const 
    { return sec.getCls(); }
    Volume_t vol(const S& sec) const 
    { return sec.getVol(); }

    //! Function call operator.
    //! It gets the close by default.
    TAfp_t operator()(const S& sec) const
    { return static_cast<TAfp_t>(sec.getCls()); }

  }; // end class


  template <class S>
  class ExtSecurityAdaptor : public SecurityAdaptor<S>
  {
  public:
    // TYPES
    typedef typename S::Price_t Price_t;
    typedef typename S::Volume_t Volume_t;

    // ACCESSORS
    Price_t opi(const S& sec) const 
    { return sec.getOpi(); }
    Price_t bid(const S& sec) const 
    { return sec.getBid(); }
    Price_t ask(const S& sec) const 
    { return sec.getAsk(); }

  }; // end class
                           

} // end namespace



#endif /* Include guard */
